package com.gzhryc.shared_device.oem.h5.agent;

import javax.servlet.http.HttpServletRequest;

import com.gzhryc.common.config.PropertyTools;

public class WebConstants {

	public final static String PROGRAM_TYPE = "h5_agent";
	public final static String PROGRAM_TYPE_NAME = "代理程序";

	public final static String CONF_RES_DOMAIN_KEY = "resDomain";
	public final static String CONF_LOCAL_RES_KEY = "localRes";

	// 页面常量
	public final static Integer PAGE_LIMIT = 30;

	/** 属性 当前登录代理 */
	public final static String ATTR_LOGIN_USER = "loginUser";

	/*
		1:输出数据库日志
	 */
	private static int debug = -1;
	public static int isDebug() {
		if(debug == -1) {
			debug = PropertyTools.get().getInt(PROGRAM_TYPE + ".isDebug", 0);
		}
		return debug;
	}
	
	public static boolean isLocalRes() {
		return PropertyTools.get().getBoolean(CONF_LOCAL_RES_KEY,false);
	}
	
	/**
	 * 获取资源域名
	 * @param request
	 * @return
	 */
	public static String getResDomain(HttpServletRequest request) {
		//检查是否使用本地资源
		boolean localRes = PropertyTools.get().getBoolean("localRes",false);
        if(localRes) {
        	return request.getContextPath();
        }else {
        	return PropertyTools.get().getString(CONF_RES_DOMAIN_KEY);
        }
	}
}
